<?php

	header("Content-Type: text/html;charset=utf-8");

	include("function/_nosql.php");

	include("function/function.php");

	include("function/letter.class.php");

	$classid = chkstr(trim($_REQUEST['classid']));
 //这段放在网站里


header("Pragma: no-cache");

$ua = strtolower($_SERVER['HTTP_USER_AGENT']);

$uachar = "/(symbianos|android|Mac OS|ucweb|blackberry)/i";

if($ua != '' && preg_match($uachar, $ua)){

echo '<script>window.location.href="http://www.chinawalking.net.cn/sj/huodong.php?class='.$classid.'";</script>';

exit();

}
	$prov = chkstr(trim($_REQUEST['prov']));

	$start_time = chkstr(trim($_REQUEST['start_time']));

	$end_time = chkstr(trim($_REQUEST['end_time']));

	$search_text = chkstr(trim($_REQUEST['search_text']));
	
	//检测变量是否为数字或数字字符串
	if(is_numeric($classid)){
		
	

		$sql="select * from kboy_bigclass where id=$classid";

		$rows=mysql_query($sql);

		$nums=mysql_num_rows($rows);

		if($nums>0){

			$rs=mysql_fetch_array($rows);

			$bigclass_cn = $rs['bigclass_cn'];

		}else{

			echo erro("该信息不存在或已被删除1");

		}

	}else{

		echo erro("参数错误");

	}

//计算符合条件的字段总和

function str_count($sql,$str){

 $res = mysql_query($sql);

 $num = mysql_num_rows($res);

 $count = 0;

  if($num>0){

	while($arr=mysql_fetch_array($res)){

	 $count = $count + $arr[$str];

	}

  }

  return $count;

}	



	

	

	// 获取父ID串

	$replace_str = "1,2,3";

	getFatherID($classid,"");

	$getFatherID = $getFatherID . ",";

	$EXarr = explode(',',$replace_str);

	foreach($EXarr as $u){

		$rep_str = ','.$u.",";

		$getFatherID = str_replace($rep_str,'',$getFatherID);

	}

	$getFatherID = rtrim(ltrim($getFatherID,','),',');

	if(strlen($getFatherID)>0){

		$Farr = array_reverse(explode(",",$getFatherID));

		$FarrNum = $Farr[0];

	}

	//排序

	function GetFistLetter($table,$field){

	    $py = new str2PY();

	    $sql_active = " select $field from $table  where 1 group by $field ORDER BY CONVERT( $field USING gbk ) COLLATE gbk_chinese_ci ASC  ";

		$res_active = mysql_query($sql_active); 

		$i=0;

		while($arr_active = mysql_fetch_array($res_active)){

		 $result = $py->getInitials(mb_substr($arr_active[$field],0,1,'utf-8'));

		 $arr[$i]['chinese'] = $arr_active[$field];

		 $arr[$i]['pinyin'] = $result;

		 $i++;

		}

		return  $arr;

	}

	

	$pinyin_list = GetFistLetter('kboy_forum_active','active_end_prov');

	$count = count($pinyin_list);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title><?= $bigclass_cn ?>_<?= $web_titles?></title>

<meta name="Keywords" content="<?= $bigclass_cn ?>,<?= $web_keywords ?>" />

<meta name="Description" content="<?= $web_description ?>" />

<link rel="stylesheet" href="css/common.css"/>

<link rel="stylesheet" href="css/activity.css"/>
<script type="text/javascript" src="js/baidutongji.js"></script>
<script type="text/javascript" src="js/laydate/laydate.js"></script>

</head>

<body>

    <!--top-bar begin-->

	<? include("_include.top.topbar.php") ?>

    <!--top-bar end-->

    <!--header begin-->

	<? include("_include.top.navbar.php") ?>

    <!--banner begin-->
	<div class="hd-banner">

        <div class="hd">

            <ul>

			<?php

				$piclink_sql = "select * from kboy_piclink where news_bigclass=296 order by news_top desc,news_order desc, id desc limit 5";

				$piclink_rows = mysql_query($piclink_sql);

				while($piclink_rs = mysql_fetch_array($piclink_rows)){

					echo "<li></li>";

				}

			?>

			</ul>

        </div>

        <div class="bd">

            <ul>

			<?php

				$piclink_sql = "select * from kboy_piclink where news_bigclass=296 order by news_top desc,news_order desc, id desc limit 5";

				$piclink_rows = mysql_query($piclink_sql);

				while($piclink_rs = mysql_fetch_array($piclink_rows)){

					echo "<li><a href=\"".$piclink_rs['news_tourls']."\" style=\"background:url(".$piclink_rs['news_pic'].") no-repeat center center\"></a></li>";

				}

			?>

            </ul>

        </div>

        <div class="hd-fast-nav">


        </div>

    </div>
    <!--<div class="hd-banner2" style="background: url(images/remen01.jpg) no-repeat center top">

        <div class="searchBox">

            <div class="innerSearch wrapper fn-pr clearfix">

                <div class="searchArea">

                    <div class="sfliter s_place fn-pr">

                        <div class="f">

                            <span class="p"><?php if($prov){ echo $prov;}else{ echo " ";} ?></span>

                            <span>目的地</span>

                        </div>

                        <b class="arrow deploy"></b>

                        <div class="fresult">

                            <div class="hotCity clearfix">

                                <label>热门出发城市</label>

                                <ul class="hotul">
                                	<li>
                                		<a href="active_class.php?classid=<?php echo $classid;?>&prov=国内" data-city="国内">国内</a>
                                	</li>
                                	<li>
                                		<a href="active_class.php?classid=<?php echo $classid;?>&prov=国外" data-city="国外">国外</a>
                                	</li>
                                </ul>

                            </div>

                            <div class="allCity tabs2">

                                <div class="ac_tab clearfix">

                                    <ul>

									<?php

									foreach($pinyin_list as $key=>$val){

									 if($key==0){ $class=" class='on'";}

									 if($key%4==0){ echo "<li ".$class.">";}

									 echo $val['pinyin'];

									 if($key%4==3 || ($key%4!=3 && ($key==($count-1))) ){ echo "</li>";}

									}

									?>

                                    </ul>

                                </div>

                                <div class="ac_box clearfix">

								 <?php

								 foreach($pinyin_list as $key=>$val){

								  if($key==0){ $on="on";}

								  if($key%4==0){ echo "<div class=\"hb1 tab-panel ".$on."\">";}

								 ?>

									<dl>

										<dt><?php echo $val['pinyin'];?></dt>

										<dd><a href="active_class.php?classid=<?php echo $classid;?>&prov=<?php echo $val['chinese'];?>"  data-city="<?php echo $val['chinese'];?>"><?php echo $val['chinese'];?></a></dd>

									</dl>

								<?php 

								 if($key%4==3 || ($key%4!=3 && ($key==($count-1))) ){ echo "</div>";}

								}

								 ?>	

                                </div>

                            </div>

 

                        </div>

                    </div>

					 <form method="post" action="active_class.php" class="search_bar">

					 <input type="hidden" name="classid" value="<?php echo $classid;?>" />
					 <input type="hidden" name="prov" value="<?php echo $prov;?>" />

                    <div class="sfliter s_type fn-pr">

                        <input type="text" class="box" name="start_time" onclick="laydate()" value="<?php echo $start_time;?>" placeholder="行程开始">

                        <b class="arrow deploy"></b>

                    </div>

                    <div class="sfliter s_type fn-pr">

                        <input type="text" class="box" name="end_time" onclick="laydate()" value="<?php echo $end_time;?>" placeholder="行程结束">

                        <b class="arrow deploy"></b>

                    </div>

                        <input type="text" name="search_text" id="searchKeyword" placeholder="请输入目的地、景点等关键词" value="<?php echo $search_text;?>">

                        <input type="submit" value="搜索" id="submit-btn">

                    </form>

                </div>

                <div class="hotkeywords">

						<label>热门关键词：</label>

						<ul>
							<?php 
							$news_sql = "select * from kboy_guan";
								
							$news_rows = mysql_query($news_sql);
								
							while($news_rs = mysql_fetch_array($news_rows)){ 
							
							?>
							<li>
								<a href="active_class.php?classid=<?php echo $classid;?>&search_text=<?php echo $news_rs['active_name'] ?>">
									<?php echo $news_rs['active_name'] ?>
								</a>
							</li>
							<?php } ?>
						</ul>

					</div>

            </div>

        </div>

    </div>-->

    <!--banner end-->

    <!--活动 begin-->

    <div class="f-item-box np">

        <div class="content">

            <div class="breadcrumb"><a href="index.php">首页</a>&gt;<a href="active_class.php?classid=<?php echo $classid;?>"><?php echo $bigclass_cn;?></a></div>

            <div class="bd-content">

                <div class="con-pane on">

                    <div class="hd-box nb">

                        <div class="hd-box-l">

                            <div class="hd-top-nav">

                                <ul>

                                    <li <?php if(intval($_GET['order']) =='1'){ echo "class='on'";} ?>><a href="active_class.php?classid=<?php echo $classid;?>&order=1">出发时间</a></li>
                                    
                                    <?php if($_GET['classid'] != 136) { ?>
                                    <li <?php if( intval($_GET['order']) =='3'){ echo "class='on'";} ?>><a href="active_class.php?classid=<?php echo $classid;?>&order=3">周末短线</a></li>
									<li  <?php if( $_GET['prov'] =='国内长线'){ echo "class='on'";} ?>><a href="active_class.php?classid=<?php echo $classid;?>&prov=国内长线" data-city="国内长线">国内长线</a></li>
									<?php }else{ ?>
									<li  <?php if( $_GET['prov'] =='国内'){ echo "class='on'";} ?>><a href="active_class.php?classid=<?php echo $classid;?>&prov=国内" data-city="国内">国内</a></li>
									<?php } ?>
										
                                	<li  <?php if( $_GET['prov'] =='国外'){ echo "class='on'";} ?>><a href="active_class.php?classid=<?php echo $classid;?>&prov=国外" data-city="国外">国外</a></li>
                                    <div class="hd-total">共计<span><?=getNewsNums("kboy_forum_active","active_bigclass=$classid")?></span>个活动</div>

                                </ul>

                            </div>
							<!--热门-->
							<div class="hd-bd-content">
        							<div class="hd-bd-list">
						<?php
								
								$order = intval($_GET['order']);

								  if($order==1 || $order == 0 ){

								   $orders = "active_center_time asc ";//出发时间

								  }

								   if($order==3){

								   $orders = " active_center_time asc ";//国内短线
									$line = "and active_tian <= 2 ";
								  }

								$prov = $_GET['prov'];
								if($prov=='国内长线')
								{
									$provs = "and active_end_prov != '国外' "; 
									$line = "and active_tian > 2 ";
								}
								if($prov=='国内')
								{
									$provs = "and active_end_prov != '国外' "; 
								}
								if($prov=='国外')
								{
									$provs = "and active_end_prov = '国外' ";
								}
								$news_sql = "select * from kboy_forum_active where active_top != '' and active_bigclass=$classid  and active_model = 0 and active_state != 2 ".$line."".$provs ;
								$news_rows = mysql_query($news_sql);
								
								$i = 1;
								while($news_rs = mysql_fetch_array($news_rows)){
						?>



                                    <dl class="hd-bd-item">

                                        <dt><a href="activeview.php?newsid=<?=$news_rs['id']?>" target="_blank"><img src="<?php  
                                       			 $news_rss = explode(',',$news_rs['active_pic']);
												if($news_rss){
													echo $news_rss[0];
												}else{
													echo $news_rs['active_pic'];
												}
                                        ?>" width="200" height="200" alt=""/></a></dt>
                                        <?php if($classid == 136){  ?>
                                        
                                        
                                        <?php }else{?>
                                        <dd>
                                            <div class="hd-info">
                                            	<div class="HOT" style="float: right;color: red;font-size: 18px;">
                                            		置顶
                                            	</div>
                                                <h3 class="title"><a href="activeview.php?newsid=<?=$news_rs['id']?>" target="_blank"><?=$news_rs['active_title']?></a></h3>
                                                <div class="editor-inner">
                                                    <span class="editor">领队：<a href="javascript:;"><?=$news_rs['active_end_user']?></a></span> 
                                                    <span class="date">联系电话 : <?=$news_rs['active_contact']?></span>
                                                    <div class="show-pl">
                                                        <span class="watch"><i></i><?=$news_rs['active_hits']?></span>
                                                        <span class="pl"><i></i><?=getNewsNums("kboy_active_message","newsid=".$news_rs['id']);?></span>
                                                        <span class="good"><i></i><?=getNewsNums("kboy_forum_favorite","newsid=".$news_rs['id']."  group by uid");?></span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="md-info">
                                                <div class="item">
                                                    <span class="icon point-c"><i></i><em style="width: 124px;"><?=$news_rs['active_start_prov']?></em></span>
                                                    <span class="icon point-q"><i></i>去往 => <em style="width: 110px;"><?=$news_rs['active_end_prov']?><?=$news_rs['active_end_city']?></em></span>
                                                    <span class="icon fun"><i></i><em>强度 : <?php
                                                    if(is_numeric($news_rs['active_power'])){
                                                    	echo getClassName("kboy_bigclass","bigclass_cn","id=".$news_rs['active_power']);
													}else{
														echo $news_rs['active_power'];
													}
                                                    ?></em>
                                                    </span>
                                                </div>
                                                <div class="item">
                                                    <span class="icon point-d"><i></i><em><?=$news_rs['active_jingdian']?></em></span>
                                                    <span class="icon time"><i></i><em><?=date('Y/m/d',strtotime($news_rs['active_start_time']))?> - <?=date('Y/m/d',strtotime($news_rs['active_end_time']))?></em></span>
                                                    <span class="final"><i class="bm">报名（<?php echo  $nums = str_count("select * from  kboy_order where order_tuiactive_content = '' and order_tui_content = '' and aid=".$news_rs['id']."  group by uid","order_num");?>）</i>/<i>余位（<?php echo ($news_rs['active_people']-$nums);?>）</i></span>
                                                </div>
                                            </div>
                                            <div class="bd-info">
                                                <ul>
                                                    <li class="bd-hd"><a href="javascript:;"><?=getClassName("kboy_bigclass","bigclass_cn","id=".$news_rs['active_bigclass'])?></a></li>
                                                    <li class="bd-pl">好评率：<span><?php echo ($news_rs['active_favor']*100);?>%</span></li>
                                                </ul>
                                            </div>
                                        </dd>
                                        <?php } ?>
                                    </dl>

						<?php

								}

						?>







 								

                                    <div class="clearfix"></div>

                                </div>


                            </div>
							<!--热门结束-->
                            <div class="hd-bd-content">

                                <div class="hd-bd-list">

								

						<?php

								$SQL = " where active_bigclass=$classid  and active_model = 0 and active_top = '' and active_state != 2 ";
								

								if($start_time !='' and $end_time ==''){

								$SQL = $SQL." and date(active_start_time) >= '".$start_time."' ";

								}

								if($end_time!='' and $start_time==''){

								$SQL = $SQL." and date(active_start_time) <= '".$end_time."' ";

								}
								

								if($start_time !='' and $end_time !=''){

								$SQL = $SQL." and date(active_start_time) between '$start_time.' and '$end_time'";

								}
								
								
								

								if($search_text){

								$SQL = $SQL." and ( `active_end_prov` like '%".$search_text."%' or `active_end_city` like '%".$search_text."%'  or  `active_jingdian` like '%".$search_text."%' ) ";

								}

								 $order = intval($_GET['order']);

								  if($order==1 || $order == 0 ){

								   $orders = "active_center_time asc ";//出发时间

								  }

								   if($order==3){

								   $orders = "active_center_time asc ";//国内短线
									$line = "and active_tian <= 2 ";
								  }

								$prov = $_GET['prov'];
								if($prov=='国内长线')
								{
									$provs = "and active_end_prov != '国外' "; 
									$line = "and active_tian > 2 ";
								}
								if($prov=='国内')
								{
									$provs = "and active_end_prov != '国外' "; 
								}
								if($prov=='国外')
								{
									$provs = "and active_end_prov = '国外' ";
								}
//								if(isset($prov))
//								{
//									if($prov != '国内长线' $$ $prov != '国内')
//									{
//									$provs = "and active_end_prov = '".$prov."' ";
//									}
//								}
								

								$pagesize = 10; // 分页数量
								
								$pageval = chkstr(trim($_REQUEST['page'])); // 获取Page的值

								if($pageval){

									if(!is_numeric($pageval)){

										echo erro("Page Error");

									}

									if($pageval <= 1){

										$pageval = 1;

									}

									$page = ($pageval-1) * $pagesize;

									$page .= ",";

								}else{

									$pageval = 1;

								}
								$pagesql = "select * from kboy_forum_active ".$SQL."".$top."".$provs."".$line."order by active_state asc,".$orders;
								$pagenum = mysql_num_rows(mysql_query($pagesql)); // 总记录数
								$pagecount = ceil($pagenum/$pagesize); // 共分多少页

								if($pageval > $pagecount){

									$pageval = $pagecount;

								}

								

								$news_sql = $pagesql." limit $page $pagesize";
								
								$news_rows = mysql_query($news_sql);
								
								$i = 1;
								while($news_rs = mysql_fetch_array($news_rows)){
										
						?>



                                    <dl class="hd-bd-item">

                                        <dt><a href="activeview.php?newsid=<?=$news_rs['id']?>" target="_blank"><img src="<?php 
                                        		$news_rss = explode(',',$news_rs['active_pic']);
												if($news_rss){
													echo $news_rss[0];
												}else{
													echo $news_rs['active_pic'];
												}
                                        	?>" width="200" height="200" alt=""/></a></dt>
                                            <?php if($classid == 136){  ?>
                                        <dd>

                                            <div class="hd-info">

                                                <h3 class="title"><a href="activeview.php?newsid=<?=$news_rs['id']?>" target="_blank"><?=$news_rs['active_title']?></a></h3>

                                            </div>

                                            <div class="md-info" style="margin:0;">

                                                <div class="item" style="height:80px;text-indent: 2em;overflow: auto;line-height: 18px;">
                                                <?php echo $news_rs['active_text']; ?>



                                                </div>

                                                <div class="item">

                                                    <span class="icon point-d"><i></i><em><?=$news_rs['active_jingdian']?></em></span>

                                                    <span class="icon time"><i></i><em><?=date('Y/m/d',strtotime($news_rs['active_start_time']))?> - <?=date('Y/m/d',strtotime($news_rs['active_end_time']))?></em></span>

                                                    <span class="final"><i class="bm">报名（<?php echo  $nums = str_count("select * from  kboy_order where order_tuiactive_content = '' and order_tui_content = '' and aid=".$news_rs['id']."  group by uid","order_num")+$news_rs['active_xianzhi']; ?>）</i>/<i>余位（<?php echo ($news_rs['active_people']-$nums);?>）</i></span>

                                                </div>

                                            </div>

                                            <div class="bd-info">

                                                <ul>

                                                    <li class="bd-hd"><a href="javascript:;"><?=getClassName("kboy_bigclass","bigclass_cn","id=".$news_rs['active_bigclass'])?></a></li>

                                                    <li class="bd-pl">好评率：<span><?php echo ($news_rs['active_favor']*100);?>%</span></li>
                                                    <li class="bd-p2da">
                                                        <div class="show-pl">

                                                        <span class="watch"><i></i><?=$news_rs['active_hits']?></span>

                                                        <span class="pl"><i></i><?=getNewsNums("kboy_active_message","newsid=".$news_rs['id']);?></span>

                                                        <span class="good"><i></i><?=getNewsNums("kboy_forum_favorite","newsid=".$news_rs['id']."  group by uid");?></span>

                                                        </div>
                                                    </li>
                                                </ul>

                                            </div>

                                        </dd>
                                        
                                             <?php }else{?>
                                        <dd>

                                            <div class="hd-info">

                                                <h3 class="title"><a href="activeview.php?newsid=<?=$news_rs['id']?>" target="_blank"><?=$news_rs['active_title']?></a></h3>

                                                <div class="editor-inner">

                                                    <span class="editor">领队：<a href="javasctipt:;"><?=$news_rs['active_end_user']?></a></span>

                                                    <span class="date">联系电话 : <?=$news_rs['active_contact']?></span>

                                                    <div class="show-pl">

                                                        <span class="watch"><i></i><?=$news_rs['active_hits']?></span>

                                                        <span class="pl"><i></i><?=getNewsNums("kboy_active_message","newsid=".$news_rs['id']);?></span>

                                                        <span class="good"><i></i><?=getNewsNums("kboy_forum_favorite","newsid=".$news_rs['id']."  group by uid");?></span>

                                                    </div>

                                                </div>

                                            </div>

                                            <div class="md-info">

                                                <div class="item">

                                                    <span class="icon point-c"><i></i><em style="width: 124px;"><?=$news_rs['active_start_prov']?></em></span>

                                                    <span class="icon point-q"><i></i>去往 => <em style="width: 110px;"><?=$news_rs['active_end_prov']?><?=$news_rs['active_end_city']?></em></span>

                                                    <span class="icon fun"><i></i><em>强度 : <?php
                                                    if(is_numeric($news_rs['active_power'])){
                                                    	echo getClassName("kboy_bigclass","bigclass_cn","id=".$news_rs['active_power']);
													}else{
														echo $news_rs['active_power'];
													}
                                                    ?></em>
                                                    </span>

                                                </div>

                                                <div class="item">

                                                    <span class="icon point-d"><i></i><em><?=$news_rs['active_jingdian']?></em></span>

                                                    <span class="icon time"><i></i><em><?=date('Y/m/d',strtotime($news_rs['active_start_time']))?> - <?=date('Y/m/d',strtotime($news_rs['active_end_time']))?></em></span>

                                                    <span class="final"><i class="bm">报名（<?php echo  $nums = str_count("select * from  kboy_order where order_tuiactive_content = '' and order_tui_content = '' and aid=".$news_rs['id']."  group by uid","order_num")+$news_rs['active_xianzhi']; ?>）</i>/<i>余位（<?php echo ($news_rs['active_people']-$nums);?>）</i></span>

                                                </div>

                                            </div>

                                            <div class="bd-info">

                                                <ul>

                                                    <li class="bd-hd"><a href="javascript:;"><?=getClassName("kboy_bigclass","bigclass_cn","id=".$news_rs['active_bigclass'])?></a></li>

                                                    <li class="bd-pl">好评率：<span><?php echo ($news_rs['active_favor']*100);?>%</span></li>

                                                </ul>

                                            </div>

                                        </dd>
                                        <?php } ?>
                                    </dl>

						<?php

								}

						?>







 								

                                    <div class="clearfix"></div>

                                </div>

						<?php
								
								if($pagenum > $pagesize){

									echo "<div class=\"pagination\"><ul>";
									
									if(isset($_GET['prov']))
									{
									$url = "active_class.php?classid=$classid&prov=$prov";
									}else{
										
									$url = "active_class.php?classid=$classid&order=$order";//当前页面
									}

									pagebar($pagecount, $pageval, 7, $url);

									echo "</ul></div>";

								}

						?>

                            </div>

                        </div>

                        <?php include_once('_include.active.rightbar.php');?>

                    </div>

                </div>

            </div>

        </div>

    </div>

    <!--客户案例-->

    

    <? //include("_include.active.footbar.php") ?>

    <!--foot begin-->

	<? include("_include.bottom.footbar.php") ?>

    <!--foot begin-->

    <!--左侧悬浮 begin-->

	<? include("_include.bottom.leftbar.php") ?>

    <!--左侧悬浮 end-->

    <!--右侧悬浮导航 begin-->

	<? include("_include.bottom.rightbar.php") ?>

    <!--右侧悬浮导航 end-->

    <script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>

    <script type="text/javascript" src="js/jquery.SuperSlide.2.1.1.js"></script>

    <script type="text/javascript" src="js/main.js"></script>

    <script type="text/javascript" src="js/activity.js"></script>

    <script type="text/javascript" src="js/activity.js"></script>

    <script type="text/javascript">

        jQuery(".hd-banner").slide({mainCell:".bd ul",effect:"leftLoop",autoPlay:true});

    </script>

</body>

</html>



